#include <iostream>
#include <thread>
using namespace std;

class Example
{
public:
    void operator()(int x)
    {
        cout << "Child id = " << this_thread::get_id() << endl;
        cout << "void Example::operator()" << endl;
        cout << "x = " << x << endl;
    }
};

int main()
{
    cout << "Main id = " << this_thread::get_id() << endl;

    Example ex;
    thread th(ex, 4); // 传入函数对象
    cout << "Child id = " << th.get_id() << endl;
    th.join(); // 主线程等待子线程执行结束
    return 0;
}